gtkflowbox: Activate items on ::unpaired-release
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 21 Nov 2017 21:35:31 +0000 (22:35 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 27 Nov 2017 00:42:03 +0000 (19:42 -0500)
If the flowbox is single-click.

https://bugzilla.gnome.org/show_bug.cgi?id=789163

gtk/gtkflowbox.c

index 6073b71f234cc03c6ae79fd89a9c8d55b572c81f..95f89ca8994625b99659c0297962dcd142269ab9 100644 (file)
@@ -2674,6 +2674,26 @@ gtk_flow_box_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
     g_signal_emit (box, signals[CHILD_ACTIVATED], 0, child);
 }
 
+static void
+gtk_flow_box_multipress_unpaired_release (GtkGestureMultiPress *gesture,
+                                          gdouble               x,
+                                          gdouble               y,
+                                          guint                 button,
+                                          GdkEventSequence     *sequence,
+                                          GtkFlowBox           *box)
+{
+  GtkFlowBoxPrivate *priv = BOX_PRIV (box);
+  GtkFlowBoxChild *child;
+
+  if (!priv->activate_on_single_click)
+    return;
+
+  child = gtk_flow_box_get_child_at_pos (box, x, y);
+
+  if (child)
+    gtk_flow_box_select_and_activate (box, child);
+}
+
 static void
 gtk_flow_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
                                           guint                 n_press,
@@ -3718,6 +3738,8 @@ gtk_flow_box_init (GtkFlowBox *box)
                     G_CALLBACK (gtk_flow_box_multipress_gesture_released), box);
   g_signal_connect (priv->multipress_gesture, "stopped",
                     G_CALLBACK (gtk_flow_box_multipress_gesture_stopped), box);
+  g_signal_connect (priv->multipress_gesture, "unpaired-release",
+                    G_CALLBACK (gtk_flow_box_multipress_unpaired_release), box);
 
   priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (box));
   gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture),